<?php
include "plugins/ckeditor/ckeditor.php";
include "plugins/ckfinder/ckfinder.php";
     
$CKEditor = new CKEditor();
$CKEditor->returnOutput = true;
$CKEditor->basePath = 'plugins/ckeditor/';              
//$CKEditor->config['width'] = 1000;                    
$CKEditor->config['height'] = 400;                    
$config['skin'] = 'kama';
  
CKFinder::SetupCKEditor($CKEditor, 'plugins/ckfinder/') ;//注意这里是相对路径，相对于根目录，不能用绝对路径
  
$contentarea = $CKEditor->editor("content", $config);//生成一个以name为content的textarea
?>

<?php 
include_once 'conn/conn.php';
$sql = mysql_query("select * from tb_type order by id");
$content_type=array();
while ($result=mysql_fetch_array($sql,MYSQL_ASSOC)){
	$content_type[]=$result;
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Ajax File Manager</title>
	<link rel="stylesheet" href="templets/css/common.css" type="text/css" />
	<meta http-equiv="Content-type" content="text/html; charset=utf8" />
</head>
<body>
<?php
header("Content-type:text/html;charset=utf-8");
if ($_POST["action"] == "post"){ 
	$type = $_POST["type"];
	$title = $_POST["title"];
	$content = $_POST["content"];
	$date = date("Y-m-d");
	
	if (($title=="" || $title == null) || ($content=="" || $content == null)){
		echo "<script type=\"text/javascript\">alert('文章标题和内容不能为空,请重新填写！');history.back();</script>";
	}else {
		$sql = mysql_query("insert into tb_content (c_type,title,content,uptime) values ('$type','$title','$content','$date')");
		if ($sql){
			echo "<script type=\"text/javascript\">alert('恭喜你，数据上传成功');window.location.href='tinymce_test.php';</script>";
		}else {
			echo "<script type=\"text/javascript\">alert('数据上传失败');window.location.href='tinymce_test.php';</script>";
		}
	}
}
?>
<div id="man_zone">
	<form action="" method="post">
		<table width="99%" border="0" align="center"  cellpadding="1" cellspacing="0" class="table_style">
			<tr>
				<td width="18%" class="left_title_2 nos">文章类别：</td>
				<td width="82%" class="nos">
					<select style="width: 120px;" name="type">
						<?php
							foreach ($content_type as $content){
						?>
						<option value="<?php echo $content[type];?>"><?php echo $content[type];?></option>
						<?php 
							}
						?>
					</select>
				</td>
			</tr>
    		<tr>
      			<td width="18%" class="left_title_1 nos"><span class="left-title">文章标题：</span></td>
      			<td width="82%" class="nos"><input type="text" name="title" /></td>
    		</tr>
    		<tr>
      			<td class="left_title_2 nos">内容：</td>
      			<td class="nos"><?php echo $contentarea;?></td>
    		</tr>
    		<tr>
				<td colspan="2" align="right" class="nos">
					<input type="submit" value="提交" />
					<input type="reset" value="重置" />
					<input type="hidden" name="action" value="post" />
				</td>
			</tr>
		</table>
	</form>
</div>
</body>
</html>